/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ronin.model;

import com.ronin.model.constant.DurumEnum;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author esimsek
 */
@Entity
@Table(name = "urun_kategori")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UrunKategori.findAll", query = "SELECT u FROM UrunKategori u"),
    @NamedQuery(name = "UrunKategori.findById", query = "SELECT u FROM UrunKategori u WHERE u.id = :id"),
    @NamedQuery(name = "UrunKategori.findBySubeId", query = "SELECT u FROM UrunKategori u WHERE u.sube.id = :subeId"),
    @NamedQuery(name = "UrunKategori.findByAd", query = "SELECT u FROM UrunKategori u WHERE u.ad = :ad")})
public class UrunKategori implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @JoinColumn(name = "sube_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Sube sube;
    @Basic(optional = false)
    @Column(name = "ad")
    private String ad;
    @OneToMany(cascade = CascadeType.REFRESH, mappedBy = "urunKategori")
    private List<Urun> urunList;
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "durum_id")
    private DurumEnum durum;
    
    @Version
    private int versiyon;


    public UrunKategori() {
    }

    public UrunKategori(Long id) {
        this.id = id;
    }

    public UrunKategori(Long id, Sube sube, String ad, DurumEnum durum) {
        this.id = id;
        this.sube = sube;
        this.ad = ad;
        this.durum = durum;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Sube getSube() {
        return sube;
    }

    public void setSube(Sube sube) {
        this.sube = sube;
    }

    public String getAd() {
        return ad;
    }

    public void setAd(String ad) {
        this.ad = ad;
    }

    @XmlTransient
    public List<Urun> getUrunList() {
        return urunList;
    }

    public void setUrunList(List<Urun> urunList) {
        this.urunList = urunList;
    }

    public DurumEnum getDurum() {
        return durum;
    }

    public void setDurum(DurumEnum durum) {
        this.durum = durum;
    }

    public int getVersiyon() {
        return versiyon;
    }

    public void setVersiyon(int versiyon) {
        this.versiyon = versiyon;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UrunKategori)) {
            return false;
        }
        UrunKategori other = (UrunKategori) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ronin.model.UrunKategori[ id=" + id + " ]";
    }
    
}
